package org.simple.wechat.demo.api;

import org.simple.wechat.demo.dto.*;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/***
 * @author gaoqijin
 * @date 2020-8-12
 * @Description
 */
@RestController
@RequestMapping("/index")
public class IndexController {

    @PostMapping
    public OrderRequestVo index(@RequestBody OrderRequest orderRequest) {

        OrderRequestVo requestVo = new OrderRequestVo();
        BeanUtils.copyProperties(orderRequest, requestVo);

        return requestVo;
    }

    @GetMapping("hello")
    public OrderRequestVo hello() {
        OrderRequestVo orderRequestVo = new OrderRequestVo();
        orderRequestVo.setExpressEnum(ExpressEnum.STO_ORDER);
        orderRequestVo.setOrderNo("HD123456789");
        orderRequestVo.setOrderLevel(OrderLevel.IMPORTANT);
        User user = new User();
        user.setName("username");
        user.setAge(19);
        orderRequestVo.setUser(user);
        return orderRequestVo;
    }


    @GetMapping
    public List<ExpressEnum> list() {
        return Arrays.asList(ExpressEnum.values());
    }

    @GetMapping("payType")
    public List<PayType> list2() {
        return Arrays.asList(PayType.values());
    }

    @GetMapping("orderLevel")
    public List<OrderLevel> list3() {
        return Arrays.asList(OrderLevel.values());
    }
}
